package com.group.three.controller.orderController;

import com.group.three.entity.myOrder.OrderComplaintDTO;
import com.group.three.service.myorderservice.OrderComplaintService;
import com.group.three.untils.SnowFlakeUtil;
import com.group.three.vo.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 买家端,交易投诉接口
 *
 * @author paulG
 * @since 2020/12/7
 **/
@RestController
@Api(tags = "买家端,交易投诉接口")
@RequestMapping("/buyer/order/complain")
public class OrderComplaintBuyerController {
    @Autowired
    private OrderComplaintService orderComplaintService;

    @ApiOperation(value = "添加交易投诉")
    @PostMapping
    public JsonResult addComplain(@Valid OrderComplaintDTO orderComplaintDTO) {
        String s = String.valueOf(SnowFlakeUtil.getSnowFlakeId());
        String substring = s.substring(0, s.length() - 3);
        orderComplaintDTO.setId(substring);
        int orderComplain = orderComplaintService.addOrderComplain(orderComplaintDTO);
        if (orderComplain == 1) {
            return new JsonResult("200", "交易数据成功");
        }
        return new JsonResult("400", "交易数据失败");
    }
}
